<template>
  <div>
    <top-bar></top-bar>
    <left-bar :datas='data'></left-bar>
    <div class="main">
      <div class="main-mains">
        <div class="main-content">
          <div class="main-mains-top">
            线上会议列表
          </div>
          <div class="main-top-nav">
            <ul>
              <router-link to="/onlineMeeting">
                <li class="active">线上会议直播列表</li>
              </router-link>
              <router-link to="/onlinebroadcast">
                <li>直播分类列表</li>
              </router-link>
            </ul>
          </div>
          <div class="screen clear">
            <div class="fl" @click="addproject()">新增</div>
            <div class="fl" @click="screen()">筛选</div>
          </div>
          <div class="publicTable toLongTable">
            <table class="head_table">
              <tr>
                <td width="3%">序号</td>
                <td width='8%'>直播间名称</td>
                <td width='6%'>任务名称</td>
                <td width='10%'>参加对象</td>
                <td width='6%'>主讲人</td>
                <td width='6%'>直播间分类</td>
                <td width='6%'>开始时间</td>
                <td width='6%'>截止时间</td>
                <td width='6%'>创建时间</td>
                <td width='5%'>是否推荐</td>
                <td width='5%'>是否显示</td>
                <td width='8%'>操作</td>
              </tr>
            </table>
            <el-scrollbar>
              <table class="content_table">
                <tr v-for="(item,index) in listData" :key="index" :class="{active:index%2==1}">
                  <td width="3%">{{index+1}}</td>
                  <td width='8%'>{{item.title}}</td>
                  <td width='6%'>{{item.topic}}</td>
                  <td width='10%'>{{participants(item.look_role_list_zh)}}</td>
                  <td width='6%'>{{item.speaker_info.speakerRealName}}</td>
                  <td width='6%'>{{item.categoryTitle}}</td>
                  <td width='6%'>{{item.begin_time}}</td>
                  <td width='6%'>{{item.end_time}}</td>
                  <td width='6%'>{{item.create_time}}</td>
                  <td width='5%' v-if="item.is_recommend==1">是</td>
                  <td width='5%' v-else>否</td>
                  <td width='5%' v-if="item.status==0">否</td>
                  <td width='5%' v-else>是</td>
                  <td width='8%' class="operation">
                    <span class="active" @click="edit(item.id)"> 编辑</span>
                    <span class="active" @click="consoleLive(item.id)">操作台</span>
                  </td>
                </tr>
              </table>
            </el-scrollbar>
          </div>
          <div class="nodataTip" v-if="showNodataTip">
            <i class="iconfont icon-zanwuneirong"></i>
            <h5>暂无内容</h5>
          </div>
          <div class="orderBotom">
            <div class="orderBotomRight">
              <el-pagination @current-change="handleCurrentChange" :page-size="15" layout="total, prev, pager, next" :total='totalnum'>
              </el-pagination>
            </div>
          </div>
        </div>
      </div>
      <div class="system-menban" v-if="search">
      </div>
      <div class="systemPopup" v-if="search">
        <div class="topTitle">
          <span>搜索</span>
          <i class="el-icon-close system-icon" @click="hideSystemPopup"></i>
        </div>
        <div class="systemPopup-con">
          <div class="systemPopup-cons clear">
            <div class="fl">状态</div>
            <div class="fl sel">
              <el-select v-model="statusType" placeholder="请选择">
                <el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </div>
          </div>
          <div class="systemPopup-cons clear">
            <div class="fl">关键词搜索</div>
            <div class="fl sel">
              <el-input placeholder="请输入关键字" v-model.trim="keyword" clearable>
              </el-input>
            </div>
          </div>
          <div class="systemPopup-btn clear">
            <div class="fl" @click="searchs()">确认</div>
            <div class="fl" @click="hideSystemPopup">取消</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import leftBar from "@/components/leftBar";
import topBar from "@/components/topBar";
import onlinemeeting from "@/api/onlinemeeting";
export default {
  components: {
    leftBar,
    topBar
  },
  data() {
    return {
      data: "onlinemeeting",
      pages: 1,
      listData: [],
      totalnum: 0,
      showNodataTip: false,
      search: false,
      time: "",
      statusType: "", //状态
      statusOptions: [
        {
          value: 1,
          label: "未启用"
        },
        {
          value: 2,
          label: "已启用"
        }
      ],
      keyword: ""
    };
  },
  methods: {
    edit(id) {
      this.$router.push("/editnlinemetting?id=" + id);
    },
    consoleLive(id) {
      this.$router.push("/consoleLive?id=" + id);
    },
    participants(value) {
      let user = [];
      let users;
      for (let i = 0; i < value.length; i++) {
        user.push(value[i].roleName);
      }
      users = user.join(",");
      return users;
    },
    addproject() {
      this.$router.push("/addonlinemetting");
    },
    screen() {
      this.search = true;
    },
    hideSystemPopup() {
      this.search = false;
    },
    handleCurrentChange(val) {
      this.pages = val;
      this.getList();
    },
    searchs() {
      this.pages = 1;
      this.getList();
    },
    getList() {
      this.showNodataTip = false;
      let options = {};
      if (this.time == null || this.time == "") {
        options = {
          page: this.pages,
          begin_time: "",
          end_time: "",
          is_show: this.statusType,
          keyword: this.keyword
        };
      } else {
        options = {
          page: this.pages,
          begin_time: this.time[0],
          end_time: this.time[1],
          is_show: this.statusType,
          keyword: this.keyword
        };
      }
      onlinemeeting.getMeetingList(options).then(res => {
        if (res.code == 1) {
          this.search = false;
          this.listData = res.data.list;
          this.totalnum = res.data.total;
          if (!res.data.total) {
            this.showNodataTip = true;
          }
        }
      });
    }
  },
  mounted() {
    this.getList();
  },
  filters: {
    times(value) {
      var time = new Date(value * 1000);
      var month =
        time.getMonth() + 1 > 9
          ? time.getMonth() + 1
          : "0" + (time.getMonth() + 1);
      var data = time.getDate() > 9 ? time.getDate() : "0" + time.getDate();
      var hour = time.getHours() > 9 ? time.getHours() : "0" + time.getHours();
      var minutes =
        time.getMinutes() > 9 ? time.getMinutes() : "0" + time.getMinutes();
      var second =
        time.getSeconds() > 9 ? time.getSeconds() : "0" + time.getSeconds();
      var times =
        time.getFullYear() +
        "-" +
        month +
        "-" +
        data +
        " " +
        hour +
        ":" +
        minutes +
        ":" +
        second;
      return times;
    }
  }
};
</script>

<style>
</style>
